<template>
	<view class="d-flex searchContent a-center j-center px-3 my-2 b-s" :style="{width:windowWidth+'px'}">
		<view class="d-flex flex-1 inputContent">
			<input class="input"
			v-model="inputvalue"
			@input="onInput" 
			placeholder="输入剧名搜索"
			placeholder-class="#e9e9e9e"
			confirm-type="search"
			@confirm="doSearch"
			type="text"></input>
		</view>
		<u-button type="warning" shape="circle" text="搜索" @click="doSearch" :customStyle="{width:'90px','margin-left':'10px'}"></u-button>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	export default {
		data() {
			return {
				inputvalue: ""
			}
		},
		props: {
			clickSearchValue: {
				type: String,
				default: ""
			}
		},
		watch: {
			clickSearchValue: {
				handler(newValue, oldValue) {
					// console.log("new:" + newValue + "old" + oldValue)
					this.inputvalue = newValue
				}
			}
		},
		computed: {
			...mapState({
				statusBarHeight: state => state.layout.statusBarHeight,
				windowWidth: state => state.layout.windowWidth,
				windowHeight: state => state.layout.windowHeight,
				platform: state => state.layout.platform
			})
		},
		methods: {
			onInput(e) { 
				//监听内容变化 console.log(this.inputvalue)
			},
			doSearch(){
				if (this.inputvalue.length == 0) {
					uni.showToast({
						icon:"none",
						title:"搜索内容不能为空",
						duration:3000,
					})
				} else{
					this.$emit("clickToSearchContentCallback", this.inputvalue)
				}
			}
		},
		mounted() {
		}
	}
</script>

<style lang="scss" scoped>
	.searchContent{
		.inputContent{
			height: 80rpx;
			border-radius: 50rpx;
			border: 2rpx solid #f9ae3d;
			.input{
				height: 100%;
				margin: 0 20px;
			}
		}
	}
</style>